package BaseObject;

public class Itinerary4 extends Itinerary{

	public Itinerary4(Client c1, Client c2) {
		super(c1,c2);
	}
	 
	public boolean computeItinerary(double base)
	{
		//Compute the minimum length for client's rides
		double probaC1 = Tools.N(15.0,5.0, Motor.currentTime - this.clientItinerary.get(0).getAppearingTime() + base * Motor.stepTime );
		this.probability = 1 - probaC1;
		
		this.length = this.clientItinerary.get(0).getPosition().distance(this.clientItinerary.get(0).getDestination());
		this.length = this.length - base;
		
		return true;
	}
	
	public void moveThisTaxi(Taxi t)
	{
		boolean change=false;

		if(t.getTekenClientList().size()==1 && t.getItinerary() != null)
		{
			//S'il a le premier client
			Client c = t.getItinerary().clientItinerary.get(0);
			if(t.getTekenClientList().get(0).equals(c))
			{
				change = t.deplacerTaxi(c.getDestination());
				if(change) 	// Si l'on arrive sur le client
				{
					Motor.clientsTaken.remove(c);
					
					t.getTekenClientList().remove(c);
					t.setItinerary(null);
					
				}
			}
			else
			{
				t.setItinerary(null);
			}
		}
	}

}
